//
//  VisitorView.swift
//  CXSwiftWB
//
//  Created by CaoXuan on 2017/5/14.
//  Copyright © 2017年 meidaer. All rights reserved.
//

import UIKit

class VisitorView: UIView {

    @IBOutlet weak var circleImg: UIImageView!

    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!
    
    class func vistorView() -> VisitorView {
        return Bundle.main.loadNibNamed("VisitorView", owner: nil, options: nil)?.last as! VisitorView
    }
    
    func setupVisitorInfo(_ imageName: String?, title: String)
    {
        startAnimation()
        titleLabel.text = title
        guard let name = imageName else {
            return
        }
        
        iconImageView.image = UIImage(named: name)
        circleImg.isHidden = true
    }
    
    private func startAnimation()
    {
        let anim = CABasicAnimation(keyPath: "transform.rotation")
        anim.toValue = Double.pi * 2
        anim.duration = 5.0
        anim.repeatCount = MAXFLOAT
        
        anim.isRemovedOnCompletion = false
        circleImg.layer.add(anim, forKey: nil)
    }

    @IBAction func regisBtnClick(_ sender: Any) {
        
        
    }
    @IBAction func loginBtn(_ sender: Any) {
        
        
    }
}
